package com.canaan.business.mapper.storehouse;

import com.canaan.business.domain.basic.WmsStorehouse;
import com.canaan.business.domain.bo.InventoryOverviewBo;
import com.canaan.business.domain.storehouse.WmsStorehouseStock;
import com.canaan.business.domain.vo.InventoryOverviewVo;
import com.canaan.business.domain.vo.OutStockQueryVo;
import com.canaan.business.domain.vo.StorehouseStockAdjustDetailVo;
import com.canaan.business.domain.vo.WmsStorehouseStockVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 * 库存Mapper接口
 *
 * @author ruoyi
 * @date 2022-11-30
 */
public interface WmsStorehouseStockMapper
{
    /**
     * 查询库存
     *
     * @param id 库存主键
     * @return 库存
     */
    public WmsStorehouseStock selectWmsStorehouseStockById(Long id);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectWmsStorehouseStockList(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectNewWmsStorehouseStockList(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 查询库存列表页面查询和导出使用
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectNewWmsStorehouseStockListPageDatas(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectWmsStorehouseStockList2(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 查询库存列表(根据物料编码分组，无条码)
     *
     * @return 库存集合
     */
    List<WmsStorehouseStock> getAllMaterialStock();

    /**
     * 根据库位获取库存信息列表
     *
     * @param locationNos 库位列表
     * @return 库存集合
     */
    public List<WmsStorehouseStock> getListByLocationNos(List<String> locationNos);

    /**
     * 根据条码获取库存信息列表
     *
     * @param barcodes 条码列表
     * @return 库存集合
     */
    public List<WmsStorehouseStock> getListByBarcodes(List<String> barcodes);

    /**
     * 新增库存
     *
     * @param wmsStorehouseStock 库存
     * @return 结果
     */
    public int insertWmsStorehouseStock(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 批量新增库存
     *
     * @param storehouseStockList 库存列表
     * @return 结果
     */
    public int batchInsertWmsStorehouseStock(List<WmsStorehouseStock> storehouseStockList);

    /**
     * 修改库存
     *
     * @param wmsStorehouseStock 库存
     * @return 结果
     */
    public int updateWmsStorehouseStock(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 批量修改库存
     *
     * @param storehouseStockList 库存列表
     * @return 结果
     */
    public int batchUpdateWmsStorehouseStock(List<WmsStorehouseStock> storehouseStockList);

    /**
     * 删除库存
     *
     * @param id 库存主键
     * @return 结果
     */
    public int deleteWmsStorehouseStockById(Long id);

    /**
     * 批量删除库存
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteWmsStorehouseStockByIds(Long[] ids);

    WmsStorehouseStock selectWmsStorehouseStockListByBarcode(String barcode);
    WmsStorehouseStock selectWmsStorehouseStockByTrayNo(String trayNo);

    void selectWmsStorehouseStockListByLocationNos(List<String> locationNos);

    /**
     * 查询库存总览
     * @param bo
     * @return
     */
    List<InventoryOverviewVo> selectInventoryOverview(InventoryOverviewBo bo);

    /**
     * 获取库存总数
     * @param storehouseNo
     * @param productNos
     * @return
     */
    List<InventoryOverviewVo> selectStockTotalQty(@Param("storehouseNo") String storehouseNo, @Param("productNos") List<String> productNos);

    /**
     * 获取库存占用总数
     * @param storehouseNo
     * @param productNos
     * @return
     */
    List<InventoryOverviewVo> selectOccupyTotalQty(@Param("storehouseNo") String storehouseNo, @Param("productNos") List<String> productNos);


    /**
     * 根据条码将库存的容器更为空
     * @param barcode
     * @return
     */
    int updateContainerByBarcode(@Param("barcode")  String barcode);

    /**
     * 查询成品库空库位（按行列从小到大）
     * @return
     */
    List<WmsStorehouseStockVo> selectEmpWmsStorehouseStockListMinRowMinColumn();

    /**
     * 查询预备库区的空库位（按行列从小到大）
     * @return
     */
    List<WmsStorehouseStockVo> selectPreStorageEmpWmsStorehouseStockListMinRowMinColumn();
    /**
     * 查询仓库列表(最大列最大行)
     *
     * @return 仓库集合
     */
    public List<WmsStorehouseStockVo> selectWmsStorehouseBigRowBigColumnList();

    /**
     * 查询成品库空库位(优先里库)
     *
     * @return 仓库集合
     */
    public List<WmsStorehouseStockVo> selectWmsStorehouseByPriorityList();
    /**
     * 查询成品库空库位(按巷道分组)
     *
     * @return 仓库集合
     */
    public List<WmsStorehouseStockVo> selectWmsStorehouseByVillageList();

    /**
     * 根据物料查询库存
     * @param outStockQueryVo 库存查询类
     * @return
     */
    List<WmsStorehouseStockVo> selectWmsStorehouseStockListByProductNos(OutStockQueryVo outStockQueryVo);

    /**
     * 根据物料查询库区库存(优先入库库区Area)
     */
    List<WmsStorehouseStockVo> selectAreaWmsStorehouseStockListByProductNos(OutStockQueryVo outStockQueryVo);

    /**
     * 查询线边仓出库空库位（按行列从小到大）
     * @return
     */
    List<WmsStorehouseStockVo> selectEmpWmsStorehouseOutStockList();

    /**
     * 查询入库接驳空库位
     * @return
     */
    WmsStorehouseStockVo selectInDockingEmptyWmsStorehouseStock();
    /**
     * 查询出库接驳空料架
     * @return
     */
    WmsStorehouseStockVo selectOutDockingEmptyShelfStorehouseStock();
    /**
     * 查询成品库空料架
     * @return
     */
    List<WmsStorehouseStockVo> selectProductEmptyShelfStorehouseStock();

    /**
     * 查询库存统计
     * @return
     */
    List<StorehouseStockAdjustDetailVo> selectWmsStorehouseStockAdjustList();

    /**
     * 根据物料查询库存的批次号
     * @param productNo 物料编号
     * @return
     */
    List<String> selectWmsStorehouseStockBatchNoByProductNo(@Param("productNo")  String productNo);
    /**
     * 更加库位编码查询库位信息
     * @return
     */
    WmsStorehouseStockVo selectStorehouseStockByLocationNo(@Param("storehouseLocationNo") String storehouseLocationNo);

    /**
     * 查询容器是否绑定库位
     * @param containerNo
     * @return
     */
    WmsStorehouseStock selectWmsStorehouseStockByContainerNo(String containerNo);

    /**
     * 绑定料架
     * @param vo
     * @return
     */
    int bindContainerNo(WmsStorehouseStockVo vo);

    /**
     * 解绑库位料架
     * @param vo
     * @return
     */
    int unbindContainerNo(WmsStorehouseStockVo vo);

    /**
     * 解绑库位料架
     * @param vo
     * @return
     */
    int unbindTrayNo(WmsStorehouseStockVo vo);

    /**
     * 根据货架号查询对应信息
     *
     * @param containerNo
     * @return
     */
    WmsStorehouseStock selectStockInfosByContainerNo(String containerNo);
}
